package insert;

import graphic.GamePanel;

import java.awt.Color;
import java.util.Random;

import model.MyVector;
import model.Particle;

public class PositionInserter extends Inserter{
	private int x;
	private int y;
	
	public PositionInserter(int x,int y){
		super();
		setX(x);
		setY(y);
	}
	
	public PositionInserter(int x,int y,int period){
		super();
		setX(x);
		setY(y);
		setPeriod(period);
	}
	
	public void setRandomColor(Particle p){
		Random ran = new Random();
		int r = 0+ran.nextInt(255);
		int g = 0+ran.nextInt(255);
		int b = 0+ran.nextInt(255);
		p.setColor(new Color(r,g,b));
	}
	
	public void insert(GamePanel panel){
		Random ran = new Random();
		
		MyVector position = new MyVector(x,y);
		MyVector velocity = new MyVector(0,0);
		MyVector acceleration = new MyVector(0,80);
		int life = ran.nextInt(400);
		Particle p = new Particle(5);
		p.setPosition(position);
		p.setVelocity(velocity);
		p.setAcceleration(acceleration);
		p.setLife(life);
		setRandomColor(p);
			
		panel.addParticle(p);
		
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
}
